/**
 * weapp-js v2.2.3(2022-4-26)
 * https://codeup.aliyun.com/motigo/motigo/weapp_base
 * Copyright@ 2022 Motigo, Inc.
 * 
 */
export default class Callback {
    constructor () {

    }
    success(opts, data) {
        this.callback(opts, 'success', data);
    }
    fail(opts, data) {
        this.callback(opts, 'fail', data);
    }
    complete(opts, data) {
        this.callback(opts, 'complete', data);
    }
    callback (opts, eventName, data) {
        if (opts && opts[eventName] && opts[eventName] instanceof Function) {
            opts[eventName](data);
        } else {
            console.error(`no ${eventName} callback`);
            return false;
        }
    }

};
